﻿#region Using directives

using Microsoft.VisualStudio.TestTools.UnitTesting;

using System;
using System.Collections.Generic;
using System.Text;

using Weazel.Gezel.Parser;
using Weazel.Gezel.Model;
using Weazel.Gezel.Model.Errors;
using Weazel.Math;

#endregion

namespace Weazel.Gezel.Parser.Test
{
  [TestClass]
  public class TestParseSequencer
  {
    [TestMethod]
    public void TestParseSequencer1()
    {
      Tokenizer t = new Tokenizer("sequencer name (my_datapath) {run;}");

      Model.Model model = new Model.Model("");

      ParseSequencer.Parse(new Set<Token>(Token.Eof), t, model);

      Controller s = model.Controllers["name"];

      Assert.AreEqual(0, t.Errors.Count);

      Assert.AreEqual("name", s.Name);
      Assert.AreEqual("my_datapath", s.DatapathRef);
      Assert.AreEqual(1, s.SignalFlowGraphRefs.Count);
      Assert.IsTrue(s.SignalFlowGraphRefs[0] == "run");
    }

    [TestMethod]
    public void TestParseSequencer2()
    {
      List<ParseError> errors = new List<ParseError>();

      ParseModel.Parse(ref errors, "sequencer ctrl(t){run;} sequencer ctrl(t){done;}");

      Assert.AreEqual(1, errors.Count);
      Assert.AreEqual(ParseErrorType.DuplicateControllerDefinition, errors[0].ErrorType);
    }
  }
}
